package com.example.mapper;

import com.example.dto.ProductDto;
import com.example.entity.OrderItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author circle48
* @description 针对表【order_item(订单项信息)】的数据库操作Mapper
* @createDate 2024-05-14 11:46:02
* @Entity com.example.entity.OrderItem
*/
@Mapper
public interface OrderItemMapper extends BaseMapper<OrderItem> {

    @Select("SELECT * FROM `order_item` WHERE order_id = #{orderId}")
    List<OrderItem> getProductsByOrderSn(Long orderId);

    @Select({"<script>",
            "SELECT * FROM order_item",
            "<where>",
            "<if test='orderId != null'>AND order_id = #{orderId}</if>",
            "<if test='spuId != null'>AND spu_id = #{spuId}</if>",
            "</where>",
            "</script>"})
    OrderItem selectByOrderIdAndSkuId(Long orderId, Long spuId);

    List<Long> selectOrderIdsByProductNameAndUser(String searchPattern, long userId);
}




